import java.util.*;
import java.math.*;

public class euler010 {
	
	static public void main(String[] params) {
		final int B = 2000000, P = (int)Math.sqrt((double)B) + 1;
		long s = 0;
		
		//Sieve of Eratosthenes
		boolean primes[] = new boolean[B];
		for(int i = 2; i < P; i++)
			if(!primes[i])
				for(j=2*i; j<primes.length; j+=i) primes[j] = true;
				
		for(i = 2; i < B; i++) s += (primes[i])?0:i;
		
		System.out.println(s);
	}
}

